package Utility
{
	public class StringUtility
	{
		public static function removeTrailingAndLeadingCharacter(char:String,str:String):String
		{
			while(str.charAt(0)==char)
			{
				str = str.slice(1);
			}
			while(str.charAt(str.length-1)==char)
			{
				str = str.slice(0,str.length-1);
			}
			return str;
		}
		
		public static function renameDuplicateTitle(str:String):String
		{
			if(str.length==0)
				return str;
			
			for(var i:int=str.length-1;i>=0;i--)
			{
				var char:String = str.charAt(i);
				
				if(!(char>="0"&&char<="9"))
				{
					if(char=="-"&&i!=str.length-1)
					{
						var num:Number = parseInt(str.substring(i+1));
						if(isNaN(num))
							return str;
						return str.substring(0,i)+"-"+(num+1).toString();
					}
					else
						return str+"-1";
				}
			}
			return str;
		}
	}
}